package loja.thinlet;

import java.io.IOException;
import java.util.ResourceBundle;

import loja.GestorCliente;
import loja.GestorStock;
import loja.JaExisteException;
import thinlet.FrameLauncher;
import thinlet.Thinlet;



/**
 * A thinlet with the contents of "<code>janelastock.xml</code>".
 */
public class WArmazemXML extends Thinlet
{

	private InterfaceXML inter;
	private GestorStock gs;
private boolean portugues;
	/**
	 * Create a new JanelastockHandler instance.
	 */
	/**
	 * @param gs
	 * @throws java.io.IOException
	 */
	public WArmazemXML(GestorStock gs, InterfaceXML inter,boolean portugues) throws java.io.IOException
	{
		if (portugues)
			setResourceBundle(ResourceBundle.getBundle("loja.thinlet.pt"));
		else
			setResourceBundle(ResourceBundle.getBundle("loja.thinlet.en"));
		this.gs = gs;
		this.inter = inter;
		
		add(parse("janelaarmazem.xml"));
	}
	

	
	/**
	 * @param nome
	 * @param descricao
	 */
	public void insere(Object nome, Object descricao)
	{
		String name = getString(nome, "text");
		String description = getString(descricao, "text");
		try {
			gs.criarArmazem(name, description);
		} catch (JaExisteException e) {
			e.printStackTrace();
		}
		inter.gerirArmazem(false);
	}
	public void cancelar(){
		inter.gerirArmazem(false);
	}
	

}
